<?php

namespace app\admin\model\yexam;

use think\Model;

class PaperBag extends Model
{
    protected $name = 'yexam_paper_bag';
    protected $autoWriteTimestamp ='int';
    protected $dateFormat = 'Y-m-d H:i:s';
    protected $append = [];
    // 类型格式化
    protected function getPaperTypeAttr($val)
    {
        switch ($val)
        {
            case 1: return '正式考试';
            case 2: return '模拟考试';
            case 3: return '付费试卷';
            case 4: return '历年真题';
        }
    }
    //====  试卷格式化
    protected function getPapersAttr($val,$data)
    {
        return $val;
        /*//////////////// 不需要显示试卷名称
         * $str = [];
        if ($data['paper_type'] == 4)
        {
            $library = new Library();
            $result = $library->where('id','in',$val)->select();
            foreach ($result as $value)
            {
                array_push($str,$value->library_name);
            }
        }else
        {
            $exams = new Exam();
            $result = $exams->where('id','in',$val)->select();
            foreach ($result as $value)
            {
                array_push($str,$value->exam_name);
            }
        }
        return implode(',',$str);*/
    }
}